package com.assistant.core.modules.sys.domain.user;

import com.auth0.jwt.interfaces.Claim;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

@Data
@Slf4j
public class Token {

    private Long id;

    public static Token fromUser(User user) {
        final Token token = new Token();
        token.id = user.getId();
        return token;
    }

    public static Token fromMap(Map<String, Claim> map) {
        final Token token = new Token();
        token.id = Long.parseLong(map.get("id").asString());
        return token;
    }

    public Map<String, String> toMap() {
        final Map<String, String> map = new HashMap<>();
        map.put("id", this.id.toString());
        return map;
    }
}
